package com.imd.s9.controller;

import com.imd.base.BaseControl;
import com.imd.base.BusinessException;
import com.imd.s9.service.IPreHookService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author cuiyu
 * @description
 * @date 2024/7/15 11:48:55
 */
@RestController
@CrossOrigin
@RequestMapping(value = "/prehook")
public class PreHookController extends BaseControl {
    @Resource
    private IPreHookService preHookService;

    @DeleteMapping("/delete/{templateId}/{entityId}")
    public void deleteEntity(@PathVariable String templateId, @PathVariable String entityId) throws BusinessException {
        preHookService.delete(templateId,entityId);
        sendResponse();
    }
    @PostMapping("/insert/{templateId}")
    public void insertEntity(@PathVariable String templateId, @RequestBody Map entity) throws BusinessException {
        preHookService.insert(templateId,entity);
        sendResponse();
    }

    @PostMapping("/update/{templateId}")
    public void updateEntity(@PathVariable String templateId, @RequestBody Map entity) throws BusinessException {
        preHookService.update(templateId,entity);
        sendResponse();
    }
}
